import pandas as pd

data = {
    "name": ["Jack", "Tom", "Alice"],
    "age": [10, 150, 200],
}

df = pd.DataFrame(data)

# 遍历行 判断-替换
for x in df.index:
    if df.loc[x, "age"] > 100:
        df.loc[x, "age"] = 100
print(df)

# 遍历行 判断-删除
df1 = pd.DataFrame(data)
for x in df1.index:
    if df1.loc[x, "age"] > 150:
        df1.drop(x, inplace=True)
print(df1)
